﻿using System;
using System.IO;
using UtilZ.Dotnet.Ex.Model;

namespace UtilZ.Dotnet.Ex.SequenceDB
{
    /// <summary>
    /// 顺序数据接口
    /// </summary>
    public interface ISequenceData
    {
        /// <summary>
        /// 数据索引
        /// </summary>
        long DataIndex { get; }

        /// <summary>
        /// 将当前对象中的数据设置到目标容器数据中
        /// </summary>
        /// <param name="dest">目标容器数据</param>
        void SetData(DataSpan<byte> dest);

        /// <summary>
        /// 从流中读取指定长度的数据到当前对象
        /// </summary>
        /// <param name="stream">数据流</param>
        /// <param name="length">数组长度</param>
        /// <returns>读取成功返回true,读取失败返回false</returns>
        bool TryRead(Stream stream, int length);

    }

    /// <summary>
    /// 顺序数据回放过滤接口
    /// </summary>
    public interface ISequenceDataFilter
    {
        /// <summary>
        /// 对回放数据进行过滤操作,该数据用来回放返回true,忽略返回false
        /// </summary>
        /// <param name="data">回放数据</param>
        /// <returns>该数据用来回放返回true,忽略返回false</returns>
        bool Filter(ISequenceData data);
    }

}
